1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
5 <key>beforeRunningCommand</key>
8 <string>#!/usr/bin/ruby
10 require ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'
11 require ENV['TM_BUNDLE_SUPPORT'] + '/lib/rails_i18n.rb'
15 # deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809
16 merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
17 merge(other, &merger)
26 self[key].set keys, value
31 project_dir = ENV['TM_PROJECT_DIRECTORY']
32 path = File.join(project_dir, 'log', 'translations')
34 translation = ENV['TM_SELECTED_TEXT'].gsub(/^\s*("|')|("|')\s*$/, '')
35 key = TextMate::UI.request_string :title => 'Key', :prompt => 'Key'
36 keys = ['en'] + key.split('.')
38 log_file = File.open(path, 'a+')
39 log_file.puts "#{key}: #{translation}"
41 data = { 'en' => {} }
42 data.set keys, translation
44 path = File.join(project_dir, 'log', 'translations.yml')
45 data = data.deep_merge YAML.load(File.open(path, 'r') { |f| f.read }) if File.exists?(path)
47 File.open(path, 'w+') { |f| f.write YAML.dump(data) }
51 <key>fallbackInput</key>
54 <string>selection</string>
55 <key>keyEquivalent</key>
58 <string>extract translation</string>
60 <string>replaceSelectedText</string>
62 <string>914BB49A-6809-425F-812E-7C3C5321D403</string>